package com.zy.smarthome;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import com.zy.smarthome.common.thread.pool.TaskThreadPoolConfig;
import com.zy.smarthome.listener.NettyServerListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableAsync;
import sun.misc.VM;

import javax.annotation.Resource;

/**
 * CommandLineRunner指定启动顺序
 *
 * @author wjming
 * @EnableConfigurationProperties({TaskThreadPoolConfig.class}) 开启配置属性支持
 */
@SpringBootApplication
@EnableEncryptableProperties
@EnableAsync

@EnableConfigurationProperties({TaskThreadPoolConfig.class})
@Slf4j
public class SocketNettyApplication implements CommandLineRunner {

    @Resource
    private NettyServerListener nettyServerListener;

    public static void main(String[] args) {
        log.info("maxDirectMemorym -> [JVM设置的缓存大小] {}", VM.maxDirectMemory() / 1024 / 1024 + "MB");
        SpringApplication.run(SocketNettyApplication.class, args);
    }

    @Override
    public void run(String... args) {
        nettyServerListener.start();
    }
}
